package com.carleasoft.mps.cms.business.article.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.carleasoft.mps.cms.business.article.bean.entity.ArticleOperationRecordEntity;
import com.carleasoft.mps.cms.business.article.dao.ArticleOperatingRecordDao;
import com.carleasoft.mps.cms.business.article.service.ArticleOperatingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author 86151
 */
@Service
public class ArticleOperatingRecordServiceImpl implements ArticleOperatingRecordService {

    @Autowired
    private ArticleOperatingRecordDao articleOperatingRecordDao;

    /**
     * 文章操作记录新增
     * @param articleOperationRecordEntity
     */
    @Override
    public int insertOperatingRecord(ArticleOperationRecordEntity articleOperationRecordEntity) {
        return articleOperatingRecordDao.insert(articleOperationRecordEntity);
    }

    /**
     * 文章操作记录擦汗寻
     * @param articleCode
     * @return
     */
    @Override
    public List<ArticleOperationRecordEntity> findByCode(String articleCode) {
        LambdaQueryWrapper<ArticleOperationRecordEntity> queryWrapper = Wrappers.<ArticleOperationRecordEntity>lambdaQuery();
        queryWrapper.in(ArticleOperationRecordEntity::getArticleCode,articleCode);
        queryWrapper.orderByAsc(ArticleOperationRecordEntity::getRecordTime);
        return articleOperatingRecordDao.selectList(queryWrapper);
    }
}
